package exteditapp.state;

import exteditapp.AppletIterator;
import exteditapp.FileDefault;
import exteditapp.command.CommandInit;

/**
 * State - application starts
 * @author Arturas Smorgun, arturas@smorgun.lt
 */
public class StateStarting extends IState {

	/**
	 * Default constructor
	 * @param iterator is system iterator, which performs all actions
	 * @param file this is file, which state we will hold
	 */
	public StateStarting(AppletIterator iterator, FileDefault file) {
		super(iterator, file);
		start();
	}
	public StateStarting(AppletIterator iterator, FileDefault file, boolean doRegister){
		super(iterator, file, doRegister);
		start();
	}
	
	protected void start() {		
		//start operation Init
		file.getModule().getInvoker().execute(new CommandInit(file));
	}
	
	/**
	 * Handling of changed state
	 */
	public boolean handle() {
		file.getModule().notifyListeners();
//		if(progress < 100){
//			System.out.println("graziname false"+Integer.toString(progress));
//			return false;
//		}
		StateIdling newState = new StateIdling(iterator, file);
		file.setCurrentState(newState);
		return true;
	}
	
}
